# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Daniel Peukert <dan.peukert@gmail.co>
# Contributor: Dimitris Kiziridis <ragouel at outlook dot com>
# Contributor: Jakob Gahde <j5lx@fmail.co.uk>

_projectname='stdio'
pkgname="ocaml-$_projectname"
pkgver=0.15.0
pkgrel=3
pkgdesc='Standard IO Library for OCaml'
arch=('loong64' 'x86_64')
url="https://github.com/janestreet/$_projectname"
license=('MIT')
depends=('glibc' 'ocaml>=4.14.0' 'ocaml-base')
makedepends=('dune')
options=('!strip')
source=("$pkgname-$pkgver-$pkgrel.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('49f2478fc08677a54bffaeb2b017d23ece19ab5c1d6c993513a20b34aeee81a7')

_sourcedirectory="$_projectname-$pkgver"

build() {
	cd "$srcdir/$_sourcedirectory/"
	OCAMLPATH=/usr/lib/ocaml dune build --release --verbose
}

package() {
	cd "$srcdir/$_sourcedirectory/"
	DESTDIR="$pkgdir" dune install --prefix '/usr' --libdir '/usr/lib/ocaml' --release --verbose

	install -dm755 "$pkgdir/usr/share/doc/$pkgname"
	mv "$pkgdir/usr/doc/$_projectname/"* "$pkgdir/usr/share/doc/$pkgname/"
	rm -r "$pkgdir/usr/doc/"

	install -dm755 "$pkgdir/usr/share/licenses/$pkgname"
	ln -sf "/usr/share/doc/$pkgname/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"
}
